package com.tbit.uqbike.client.dto;

import lombok.Data;

/**
 * 白名单校验结果
 *
 *
 * @author <a href="mailto:chen.chaoxiong@tbit.com.cn">ChenChaoXiong</a>
 * @since 2024/5/10
 */
@Data
public class WhiteListCheckResultDTO {

    //容量无限制
    private static final int UNLIMITED_CAPACITY = 999999;

    //无
    private static final int NO_CAPACITY = -1;



    /**
     * 认证编号
     */
    private String authNo;

    /**
     * 是否在白名单中
     */
    private boolean inWhiteList;

    /**
     * 白名单容量
     */
    private int capacity;

    /**
     * 白名单剩余容量
     */
    private int remainCapacity;

    public static WhiteListCheckResultDTO notFound(String authNo) {
        WhiteListCheckResultDTO result = new WhiteListCheckResultDTO();
        result.setAuthNo(authNo);
        result.setInWhiteList(false);
        result.setCapacity(NO_CAPACITY);
        result.setRemainCapacity(NO_CAPACITY);
        return result;
    }

    public static WhiteListCheckResultDTO unlimited(String authNo) {
        WhiteListCheckResultDTO result = new WhiteListCheckResultDTO();
        result.setAuthNo(authNo);
        result.setInWhiteList(true);
        result.setCapacity(UNLIMITED_CAPACITY);
        result.setRemainCapacity(UNLIMITED_CAPACITY);
        return result;
    }

    public static WhiteListCheckResultDTO of(String authNo, int capacity, int remainCapacity) {
        WhiteListCheckResultDTO result = new WhiteListCheckResultDTO();
        result.setAuthNo(authNo);
        result.setInWhiteList(remainCapacity> 0);
        result.setCapacity(capacity);
        result.setRemainCapacity(remainCapacity);
        return result;
    }
}
